﻿using System.Collections.Generic;

namespace ClassLibrary
{
    /// <summary>
    /// 错误消息队列
    /// </summary>
    public class ErrMessageQueue
    {
        private Queue<ErrMessage> errList;

        public ErrMessageQueue()
        {
            errList = new Queue<ErrMessage>();
        }

        /// <summary>
        /// 将错误信息添加到结尾处
        /// </summary>
        /// <param name="err"></param>
        public void Enqueue(string err)
        {
            errList.Enqueue(new ErrMessage { date = System.DateTime.Now + ":", err = err });
        }

        /// <summary>
        /// 移除并返回位于开始处的错误信息
        /// </summary>
        /// <returns></returns>
        public ErrMessage Dequeue()
        {
            return errList.Dequeue();
        }

        public int Count
        {
            get => errList.Count;
        }

    }
    public class ErrMessage
    {
        public string date { get; set; }
        public string err { get; set; }
    }

}
